Skip to content

Conversation

ntrevino-virtru
Copy link
Contributor

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ntrevino-virtru, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a comprehensive update to the core key management and policy enforcement mechanisms within the system. It introduces new data models and refactors existing client-side logic to provide more explicit control over Key Access Server (KAS) key identification, management, and their association with policy attributes. Additionally, it enhances OpenID Connect (OIDC) integration by allowing configurable endpoints and lays groundwork for advanced key lifecycle management features.

Highlights

  • Key Management Overhaul: Introduced new SimpleKasKey, PublicKeyCtx, and PrivateKeyCtx types, and updated core policy objects (Namespace, Attribute, Value, KeyAccessServer) to utilize these new, more explicit key representations. This includes changes to how KAS keys are associated with attributes and values.
  • Enhanced Key Modes: Expanded the KeyMode enum with detailed classifications like CONFIG_ROOT_KEY, PROVIDER_ROOT_KEY, and PUBLIC_KEY_ONLY, providing more granular control over key management strategies.
  • Configurable OIDC Endpoints: Added the capability to explicitly configure OIDC token and user info endpoints within authentication providers, enhancing flexibility for OIDC integration.
  • Key Rotation and Base Key Management: Introduced new RPC methods (SetBaseKey, GetBaseKey) and response structures (RotatedResources) in the KAS registry, enabling more robust management and tracking of key rotations.
  • Client-Side Key Resolution Refactor: The TDF3 client's key resolution logic was significantly refactored to use a caching mechanism for KAS public keys and to correctly handle various public key contexts (remote, cached) during the encryption process, including the use of explicit Key IDs (kid).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ntrevino-virtru
Copy link
Contributor Author

Reated to #622

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several significant changes, primarily focused on enhancing OIDC endpoint configurability and refactoring how key identifiers and attributes are handled, particularly within the policy and TDF3 client logic.

Key changes include:

  • Adding oidcTokenEndpoint and oidcUserInfoEndpoint options for more flexible OIDC integration.
  • Substantial updates to Protobuf definitions, including new message types (SimpleKasKey, PublicKeyCtx, etc.), changes to existing enums (KeyStatus, KeyMode), and the removal of google.api.http options from many gRPC services. These are potentially breaking changes that need careful consideration and documentation.
  • Refactoring of the policy granter logic to use KeyAccessServer objects more directly and incorporate kid (Key ID) into the key splitting plan, aligning with the PR's goal of using key IDs per attribute.
  • Updates to the TDF3 client to support these new KAS key handling mechanisms, including a more detailed splitPlan and caching for KAS public key fetching.

Several critical issues have been identified, primarily related to the Protobuf changes, such as the removal of HTTP/JSON transcoding annotations and a suspicious field name/type swap in RotateKeyRequest_NewKey. These require immediate attention. The PR description should be updated to reflect these significant changes and their potential impact.

…ey-ids-per-attribute

# Conflicts:
#	lib/src/opentdf.ts
#	lib/tdf3/src/client/index.ts
@ntrevino-virtru ntrevino-virtru marked this pull request as ready for review June 23, 2025 15:38
@ntrevino-virtru ntrevino-virtru requested a review from a team as a code owner June 23, 2025 15:38
@@ -282,7 +295,7 @@ export function valueFor(attr: string): Value {
if (!(attr in values)) {
throw new Error(`invalid FQN [${attr}]`);
}
console.log('value for', attr, 'is', values[attr]);
// console.log('value for', attr, 'is', values[attr]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this?

? splitPlan
: [{ kas: opts.defaultKASEndpoint ?? this.kasEndpoint }];
// TODO KAS: check here
if (splitPlan.length === 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably will have Eugene's base key work here I believe.

const splits: SplitStep[] = splitPlan?.length
? splitPlan
: [{ kas: opts.defaultKASEndpoint ?? this.kasEndpoint }];
// TODO KAS: check here
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link

@c-r33d c-r33d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing the step where we are adding SimpleKasKeys to the kasKeys cache? The flow should be the following:
An attribute comes back with:

  • Grants/SimpleKasKeys

If we notice that the response has KasKeys we use those instead of the grants returned, else use the grants.

Example of this in the golang sdk:
https://github.com/opentdf/platform/blob/main/sdk/granter.go#L287-L304

Copy link

sonarqubecloud bot commented Jul 9, 2025

return [keyHolder, keyParts.join('/')] as [KeyHolder, string];
})
.sort(([, sortKeyA], [, sortKeyB]) => {
return sortKeyA.localeCompare(sortKeyB);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice 🔥

Copy link
Contributor

@eugenioenko eugenioenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the code changes and LGTM

@ntrevino-virtru ntrevino-virtru merged commit b37e736 into main Jul 9, 2025
32 of 36 checks passed
@ntrevino-virtru ntrevino-virtru deleted the chore/dspx-1226/use-key-ids-per-attribute branch July 9, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants